/*    */ package com.zimbra.cs.mailbox.calendar;
/*    */ 
/*    */ import com.zimbra.common.auth.ZAuthToken;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.soap.Element.XMLElement;
/*    */ import com.zimbra.common.soap.SoapFaultException;
/*    */ import com.zimbra.common.soap.SoapTransport;
/*    */ import com.zimbra.common.util.CliUtil;
/*    */ import com.zimbra.cs.util.SoapCLI;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintStream;
/*    */ import org.apache.commons.cli.CommandLine;
/*    */ import org.apache.commons.cli.Option;
/*    */ import org.apache.commons.cli.Options;
/*    */ import org.apache.commons.cli.ParseException;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class FixCalendarEndTimeUtil
/*    */   extends SoapCLI
/*    */ {
/*    */   protected static final String O_ACCOUNT = "a";
/*    */   protected static final String O_SYNC = "sync";
/*    */   
/*    */   protected void setupCommandLineOptions()
/*    */   {
/* 39 */     super.setupCommandLineOptions();
/* 40 */     Options options = getOptions();
/* 41 */     Option accountOpt = new Option("a", "account", true, "account email addresses seperated by white space or \"all\" for all accounts");
/*    */     
/* 43 */     accountOpt.setArgs(-2);
/* 44 */     options.addOption(accountOpt);
/* 45 */     options.addOption(new Option(null, "sync", false, "run synchronously; default is asynchronous"));
/*    */     
/* 47 */     options.addOption(SoapCLI.OPT_AUTHTOKEN);
/* 48 */     options.addOption(SoapCLI.OPT_AUTHTOKENFILE);
/*    */   }
/*    */   
/*    */   protected String getCommandUsage() {
/* 52 */     return "zmfixcalendtime -a <account(s)> [options]";
/*    */   }
/*    */   
/*    */   public FixCalendarEndTimeUtil() throws ServiceException
/*    */   {
/* 57 */     setupCommandLineOptions();
/*    */   }
/*    */   
/*    */   public static void main(String[] args) {
/* 61 */     CliUtil.toolSetup();
/* 62 */     FixCalendarEndTimeUtil util = null;
/*    */     try {
/* 64 */       util = new FixCalendarEndTimeUtil();
/*    */     } catch (ServiceException e) {
/* 66 */       System.err.println(e.getMessage());
/* 67 */       System.exit(1);
/*    */     }
/*    */     try {
/* 70 */       CommandLine cl = util.getCommandLine(args);
/* 71 */       if (cl == null)
/* 72 */         return;
/* 73 */       util.doit(getZAuthToken(cl), cl.getOptionValues("a"), cl.hasOption("sync"));
/* 74 */       System.exit(0);
/*    */     } catch (ParseException e) {
/* 76 */       util.usage(e);
/*    */     } catch (Exception e) {
/* 78 */       System.err.println("Error occurred: " + e.getMessage());
/* 79 */       util.usage(null);
/*    */     }
/* 81 */     System.exit(1);
/*    */   }
/*    */   
/*    */   private void doit(ZAuthToken zat, String[] accts, boolean sync) throws SoapFaultException, IOException, ServiceException
/*    */   {
/* 86 */     Element req = new Element.XMLElement(AdminConstants.FIX_CALENDAR_END_TIME_REQUEST);
/* 87 */     if ((accts == null) || (accts.length == 0))
/* 88 */       throw ServiceException.INVALID_REQUEST("Missing -a option", null);
/* 89 */     for (String acct : accts) {
/* 90 */       Element acctElem = req.addElement("account");
/* 91 */       acctElem.addAttribute("name", acct);
/*    */     }
/* 93 */     if (sync) {
/* 94 */       req.addAttribute("sync", true);
/*    */     }
/* 96 */     auth(zat);
/* 97 */     getTransport().invokeWithoutSession(req);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/mailbox/calendar/FixCalendarEndTimeUtil.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */